/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.me.stepapp.server;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Peter
 */
@Entity
@Table(name = "STEPAPP_FRIEND")
@NamedQueries({
    @NamedQuery(name = "StepappFriend.findAll", query = "SELECT s FROM StepappFriend s"),
    @NamedQuery(name = "StepappFriend.findByUserId", query = "SELECT s FROM StepappFriend s WHERE s.stepappFriendPK.userId = :userId"),
    @NamedQuery(name = "StepappFriend.findByFriendsId", query = "SELECT s FROM StepappFriend s WHERE s.stepappFriendPK.friendsId = :friendsId")})
public class StepappFriend implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected StepappFriendPK stepappFriendPK;
    @Lob
    @Column(name = "BLOCKED")
    private byte[] blocked;
    @Lob
    @Column(name = "REQUEST_PENDING")
    private byte[] requestPending;
    @JoinColumn(name = "FRIENDS_ID", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private StepappUser stepappUser;
    @JoinColumn(name = "USER_ID", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private StepappUser stepappUser1;

    public StepappFriend() {
    }

    public StepappFriend(StepappFriendPK stepappFriendPK) {
        this.stepappFriendPK = stepappFriendPK;
    }

    public StepappFriend(int userId, int friendsId) {
        this.stepappFriendPK = new StepappFriendPK(userId, friendsId);
    }

    public StepappFriendPK getStepappFriendPK() {
        return stepappFriendPK;
    }

    public void setStepappFriendPK(StepappFriendPK stepappFriendPK) {
        this.stepappFriendPK = stepappFriendPK;
    }

    public byte[] getBlocked() {
        return blocked;
    }

    public void setBlocked(byte[] blocked) {
        this.blocked = blocked;
    }

    public byte[] getRequestPending() {
        return requestPending;
    }

    public void setRequestPending(byte[] requestPending) {
        this.requestPending = requestPending;
    }

    public StepappUser getStepappUser() {
        return stepappUser;
    }

    public void setStepappUser(StepappUser stepappUser) {
        this.stepappUser = stepappUser;
    }

    public StepappUser getStepappUser1() {
        return stepappUser1;
    }

    public void setStepappUser1(StepappUser stepappUser1) {
        this.stepappUser1 = stepappUser1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (stepappFriendPK != null ? stepappFriendPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof StepappFriend)) {
            return false;
        }
        StepappFriend other = (StepappFriend) object;
        if ((this.stepappFriendPK == null && other.stepappFriendPK != null) || (this.stepappFriendPK != null && !this.stepappFriendPK.equals(other.stepappFriendPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.me.stepapp.server.StepappFriend[stepappFriendPK=" + stepappFriendPK + "]";
    }

}
